<?php
namespace Modules\ShopApi\Http\Controllers\v1;
use Illuminate\Http\Request;
use Modules\ShopApi\Http\Requests\ProductListRequest;
use Modules\ShopApi\Http\Requests\ProductCommentsListRequest;
use Modules\ShopApi\Http\Requests\IDMustBePositiveIntRequest;
use Modules\ShopApi\Models\Picture as PictureModel;
use Modules\ShopApi\Models\ShopProduct as ShopProductModel;
use Modules\ShopApi\Models\ShopProductType as ShopProductTypeModel;
use Modules\ShopApi\Models\ShopTopSearche as ShopTopSearcheModel;
use Modules\ShopApi\Models\ShopProductComment as ShopProductCommentModel;
use Modules\ShopApi\Models\ShopCollect as ShopCollectModel;
class IndexController extends CommonController
{
	/**
	 * @name  首页轮播图
	 * @method  GET	
	 * @return  JSON	
	 */
    public function baner_list(Request $request)
    { 
        return (new PictureModel())->baner_list(2);
    }
	/**
	 * @name  轮播图详情
	 * @method  GET	
	 * @param  id 图片id
	 * @return  JSON
	 */
    public function swiper_detail(IDMustBePositiveIntRequest $request)
    { 
        return (new PictureModel())->swiper_detail($request->get('id'));
    }
	/**
	 * @name  首页商品分类
	 * @method  GET	
	 * @return  JSON	
	 */
    public function product_type(Request $request)
    { 
        return (new ShopProductTypeModel())->product_type();
    }
	/**
	 * @name  首页精品推荐 
	 * @method  GET	
	 * @param page 页码
	 * @return  JSON	
	 */
    public function recommend_product_list(Request $request)
    { 
        return (new ShopProductModel())->recommend_product_list(1,$request->get('page'));
    }
	/**
	 * @name  首页热卖单品  
	 * @method  GET	
	 * @param page 页码
	 * @return  JSON
	 */
    public function best_product_list(Request $request)
    { 
        return (new ShopProductModel())->recommend_product_list(2,$request->get('page'));
    }
	/**
	 * @name  商品列表
	 * @method  GET	
	 * @param type 类型 1=首页列表，2=精品推荐，3=热卖单品，4=所有商品
	 * @param page 页码 
	 * @param name 商品名称
	 * @param sales 销量：1=从多到少，0=从少到多
	 * @param new_products 是否新品：1=是，0=否
	 * @param size_money 综合：0=默认，1=价格升序，2=价格降序
	 * @param product_type_id 商品分类id
	 * @return  JSON
	 */
    public function product_list(ProductListRequest $request)
    { 
        return (new ShopProductModel())->product_list($request->all());
    }
	/**
	 * @name  商品详情
	 * @method  GET	
	 * @param  id 商品id
	 * @return  JSON
	 */
    public function product_info(IDMustBePositiveIntRequest $request)
    { 
        return (new ShopProductModel())->product_info($request->get('id'));
    }
	/**
	 * @name  商品收藏
	 * @method  POST	
	 * @param  id 商品id
	 * @return  JSON
	 */
    public function product_collect(IDMustBePositiveIntRequest $request)
    { 
        return (new ShopCollectModel())->product_collect($request->get('id'));
    }
	/**
	 * @name  热搜列表  
	 * @method  GET	
	 * @return  JSON
	 */
    public function top_search_list(Request $request)
    { 
        return (new ShopTopSearcheModel())->top_search_list($request->get('searches_status'));
    }
	/**
	 * @name  商品评价列表
	 * @method  GET	
	 * @param id 商品id
	 * @param page 页码
	 * @return  JSON
	 */
    public function product_comments_list(ProductCommentsListRequest $request)
    { 
        return (new ShopProductCommentModel())->product_comments_list($request->all());
    }
}
